package com.csu.csumall.VO;

import com.csu.csumall.entity.Order;
import com.csu.csumall.entity.OrderItem;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.util.List;

/**
 * 用于展示历史订单列表中条目
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderItemVO {
    private Integer orderId;
    private Integer orderStatus;
    private List<OrderProductVO> orderProductVOList;

    public OrderItemVO(Order order, List<OrderItem> orderItemList) {
        orderId = order.getId();
        orderStatus = order.getStatus();
        orderItemList.forEach(orderItem -> {
            orderProductVOList.add(new OrderProductVO(orderItem));
        });
    }

}
